<?
	function showerror($error)   {
		$xml = $error->getXML();
		$xml = '<?xml version="1.0"?>'."\n".$xml;
		$length = strlen($xml);
		header('Connection: close');
		header('Content-Length: '.$length);
		header('Content-Type: text/xml');
		header('Date: '.date('r'));
		echo $xml;
	}

	if ($_POST['method'] != '') {
		include('class/xmlrpc.class.php');
		$params = $_POST['params'];
		$client = new IXR_Client('http://meridon.bulix.org/~sam/fgs/backend/backend.php');

		switch ($_POST['method'])  {
	
			case 'user.getgamelist': 
				if (!$client->query('user.getgamelist')) {
					$error = new IXR_Error(
						$client->getErrorCode(),
						$client->getErrorMessage()
					);
					showerror($error);
					exit;
				}
				break;
	
			case 'user.getserverlist': 
				if (!$client->query('user.getserverlist', $params[0])) {
					$error = new IXR_Error(
						$client->getErrorCode(),
						$client->getErrorMessage()
					);
					showerror($error);
					exit;
				}
				break;
	
			case 'user.login': 
				if (!$client->query('user.login', $params[0], md5($params[1]))) {
					$error = new IXR_Error(
						$client->getErrorCode(),
						$client->getErrorMessage()
					);
					showerror($error);
					exit;
				}
				break;

			case 'user.verify': 
				if (!$client->query('user.verify', $params[0], $params[1])) {
					$error = new IXR_Error(
						$client->getErrorCode(),
						$client->getErrorMessage()
					);
					showerror($error);
					exit;
				}
				break;

			case 'news.getnewslist': 
				if (!$client->query('news.getnewslist')) {
					$error = new IXR_Error(
						$client->getErrorCode(),
						$client->getErrorMessage()
					);
					showerror($error);
					exit;
				}
				break;

		}

		echo '<pre>';
		echo htmlentities($client->message->message);
		print_r($client->getResponse());
		echo '</pre>';
		exit;
	}
?>
